<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
    <meta http-equiv="X-UA-Compatible" content="ie=edge,chrome=1">
    <meta name="referrer" content="never">
    <title>操作属性</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
        ul {
            list-style: none;
        }

        .box{
            position: absolute;
            top: 50px;
            left: 50px;
            width: 150px;
            height: 150px;
            background-color: #f00;
        }
    </style>
</head>
<body>
    
    <div class="box"></div>
    <script src="../lib/jquery/jquery.min.js"></script>
    <script type="text/javascript">
        /*
            $ele.attr(propName) 获取属性
            $ele.attr(propName, propValue) 设置属性
            $ele.attr({  设置多个属性
                propName: propValue,
                propName: propValue,
                propName: propValue
                ...
            }) 
            $ele.removeAttr(propName) 删除属性 
        */

        var $box = $(".box");

        console.log($box.attr("class")); // box
        $box.attr("title", "hello"); // box
        $box.attr({
            "data-title": "你好啊",
            style: "width: 200px"
        }); // box

        $box.removeAttr("title");
    </script>
</body>
</html>